package cn.org.zx.login.blh;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import cn.org.zx.common.commutils.DBTimeServer;
import cn.org.zx.common.commutils.StringUtils;
import cn.org.zx.common.log.LogWritter;

public class LoginBlh {
	//系统管理员用户登录
	public Map getLogin_M(Map mapData,String strip,String sessrandcode){
		Map<String, Object> mapReturn = new HashMap<String, Object>();
		
		String stracccount = StringUtils.toString(mapData.get("laccount_m"));
		String strpassword = StringUtils.toString(mapData.get("lpassword_m"));
		String strrandcode = StringUtils.toString(mapData.get("lrandomnum_m"));
		String strLoginDateTime = "";
		
		if(sessrandcode.equals(strrandcode)){
			if(stracccount.equals("admin") && strpassword.equals("123456")){
				strLoginDateTime = DBTimeServer.getServerTimestamp().toString();			
				
				Date date = new Date();
				SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				String strDate = format.format(date);
				LogWritter.loginInfo("用户："+stracccount+"于"+strDate+"登录,请求IP:"+strip);
				
				mapReturn.put("logindate",strLoginDateTime);
				mapReturn.put("utype", "success");							
			}
			else{
				mapReturn.put("utype", "fail");		
			}
		}
		else{
			mapReturn.put("utype", "randcode");			
		}
		
		return mapReturn;
	}
}
